package com.sy.simpleegg.serialport.banknote

import com.sy.simpleegg.ext.logFile
import org.cnbleu.serialport.SerialPort

class BanknoteController(
    portName: String,
    baudrate: SerialPort.BAUDRATE,
    stopb: SerialPort.STOPB,
    datab: SerialPort.DATAB,
    parity: SerialPort.PARITY,
    private val listener: MoneyListener,
    speed: Long = 10L
): BanknoteBaseController(portName, baudrate, stopb, datab, parity, speed) {

    init {
        logFile("打开纸钞机，串口号=$portName 波特率=$baudrate 停止位=$stopb 数据位=$datab 校验位=$parity")
    }

    override fun getMoney(checkMoney: Long, totalMoney: Long) {
        listener.getMoney(checkMoney, totalMoney)
    }

    override fun recieveMoney(tempMoney: Long, checkMoney: Long) {
        listener.recieveMoney(tempMoney, checkMoney)
    }

    interface MoneyListener{
        fun getMoney(checkMoney: Long, totalMoney: Long)

        fun recieveMoney(tempMoney: Long, checkMoney: Long)
    }

}